package com.example.administrator.funclient;


import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Xfermode;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

public class ClientTextView extends TextView {
    Paint paint;
    Xfermode xfermode;
    public ClientTextView(Context context) {
        super(context);
    }

    public ClientTextView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.STROKE);
        xfermode = new PorterDuffXfermode(PorterDuff.Mode.XOR);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        drawPop(canvas);
        super.onDraw(canvas);
    }

    Path path = new Path();
    private void drawPop(Canvas canvas) {
        int saver = canvas.saveLayer(0,0,getWidth(),getHeight(),getPaint());
        canvas.drawRect(11,1,getWidth() -1, getHeight() -1,paint);
        paint.setXfermode(xfermode);
        path.reset();
        path.moveTo(11,2);
        path.lineTo(1,2 + 5);
        path.lineTo(11,2 + 5 + 5);
        path.close();
        canvas.drawPath(path,paint);
        paint.setXfermode(null);
        canvas.restoreToCount(saver);
    }
}
